#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <sys/shm.h>
#include <dirent.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/stat.h>

int ReadDir(const char *path);

int main()
{
	ReadDir("/home/work/share64/account");
}

int ReadDir(const char *path)
{
	DIR *dir;
	struct dirent *d_stat;
	char file[512] = {0};
	char csv[512] = {0};
	struct stat f_stat;
	int ret;
	
	dir = opendir(path);
	if(!dir){
		printf("opendir %s failed \n",path);
		perror("openfile");
		return -1;
	}
	
	while(d_stat = readdir(dir)){
		if(!strcmp(d_stat->d_name, ".") || !strcmp(d_stat->d_name, "..")){
			continue;
		}
		
		memset(file, 0, sizeof(file));
		memset(&f_stat, 0, sizeof(f_stat));
		sprintf(file, "%s/%s",path, d_stat->d_name);
		stat(file, &f_stat);
		if(!strcmp(d_stat->d_name, "tcuaccount.db")){
			
		}else if(S_IFREG & f_stat.st_mode)
			remove(file);
		else if(S_IFDIR & f_stat.st_mode)
			ReadDir(file);
		
	}
	closedir(dir);
	
	return 0;
}